package org.MyToolsProject.gather;

import chan.module.project.comm.PropertiesUtil;
import org.MyToolsProject.gather.target.ChinaMobile;
import org.MyToolsProject.gather.target.ChinaTele;
import org.MyToolsProject.gather.target.Cuecp;
import org.MyToolsProject.gather.target.Tower;

import java.io.File;
import java.util.Properties;

public class GatherData {
    public static void main(String[] args) {
        String configPath = null;
        for (String param : args){
            if(param.startsWith("config=")){
                configPath = param.replace("config=","");
                break;
            }
        }
        if(configPath == null){
            System.err.println("需要有配置文件路径！");
            return;
        }
        File configFile = new File(configPath);
        if(!configFile.exists()){
            System.err.println("配置文件[" + configFile +"] 不存在！");
            return;
        }
        //10086-中国移动 tower-中国铁塔 cuecp-中国连通,chinatele-中国电信
        PropertiesUtil propertiesUtil = new PropertiesUtil(configPath);
        Properties prop = propertiesUtil.getProp();
        String target = prop.getOrDefault("target.website", "").toString();
        if(target.contains("10086")){
            ChinaMobile chinaMobile = new ChinaMobile(prop);
            chinaMobile.start();
        }
        if(target.contains("tower")){
            Tower tower = new Tower(prop);
            tower.start();
        }
        if(target.contains("cuecp")){
            Cuecp cuecp = new Cuecp(prop);
            cuecp.start();
        }
        if(target.contains("chinatele")){
            ChinaTele chinaTele = new ChinaTele(prop);
            chinaTele.start();
        }
    }
}
